Skip to content

fix: preserve aliased native constructor proofs - #8278

Merged
proggeramlug merged 2 commits into
mainfrom
fix/8222-aliased-native-class-import
Aug 17, 2026
Merged

fix: preserve aliased native constructor proofs#8278
proggeramlug merged 2 commits into
mainfrom
fix/8222-aliased-native-class-import

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

  • preserve canonical runtime type proofs for constructors imported from native modules
  • recover aliased named imports through their original export names
  • reject non-class, non-native, and ambiguous import-source proofs

Testing

  • cargo test -p perry-codegen --lib imported_native_constructor_proof --release -- --nocapture
  • cargo test -p perry --test aliased_native_class_import --release aliased_net_socket_keeps_native_methods -- --exact --nocapture
  • cargo test -p perry --test aliased_native_class_import --release aliased_matches_unaliased_for_native_class -- --exact --nocapture
  • cargo fmt -p perry-codegen -- --check
  • python scripts/check_test_registration.py

Fixes #8222

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Limit details: You’ve used all 8 included reviews currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 58ffbe09-8974-40a9-a7fc-d4876d850783

📥 Commits

Reviewing files that changed from the base of the PR and between 259a225 and 706c31b.

📒 Files selected for processing (4)
  • changelog.d/8278-aliased-native-constructor-proofs.md
  • crates/perry-codegen/src/type_analysis.rs
  • crates/perry-codegen/src/type_analysis/refine.rs
  • crates/perry-codegen/src/type_analysis_tests.rs
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/8222-aliased-native-class-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Merging. This clears #8222, which #8273 named as one of the remaining full-suite-gate blockers.

The design is fail-closed in the direction that matters. A wrong proof here is a miscompile — native method dispatch applied to a class that isn't native — so is_imported_native_constructor_class refusing in every doubtful case is right: two candidate sources resolving to different modules returns false, no resolved source returns false, and even then the API_MANIFEST must carry a matching module + name + ApiKind::Class. Recovering the alias by scanning imported_class_original_names for locals whose original is the canonical name is the piece that was missing, and it's chained with the direct lookup rather than replacing it.

Verified here:

  • cargo test -p perry --test aliased_native_class_import7 passed, 0 failed, and crucially that includes aliased_user_class_import_is_not_treated_as_native. A proof-granting change whose tests only cover the granting direction would be half-tested; this covers the refusal too.
  • cargo test -p perry-codegen --no-fail-fast — 24 suites, 1480 passed, 8 failed, all eight in the known baseline. (The first run stopped at 23 suites when the disk filled; I ran typed_shape_descriptors separately — 18 passed, 0 failed — rather than report a partial sweep as a clean one.)
  • cargo fmt --all --check, check_test_registration.py, check_file_size.sh all clean.

@proggeramlug
proggeramlug merged commit 46156e6 into main Aug 17, 2026
27 of 33 checks passed
@proggeramlug
proggeramlug deleted the fix/8222-aliased-native-class-import branch August 17, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo-test (full): aliased native-class import loses native methods (aliased_native_class_import, 2 tests)

1 participant